package com.wq.gof.designer.chain.pointer;

/**
 * @Author: wangqiang20995
 * @Date:2019/1/25
 * @Description:
 * @Resource:
 */
public class HighFrequencyEventHandler extends AbstractPointerEventHandler {

    private static final Integer HIGH_FREQUENCY = 1000;

    @Override
    public void doHandler(String name, Integer level) {
        //两个return是必须的，符合条件的handler处理完了之后，假如它前面还有handler那么回调的哪行方法之后的代码就不会继续执行，而是直接返回
        if (level.intValue() > HIGH_FREQUENCY) {
            getNextHandler().doHandler(name, level);
            return;
        }

        System.out.println("高频率的handler处理[" + name + "]的[" + level + "]请求");
        return;
    }

    @Override
    public long frequency() {
        return HIGH_FREQUENCY;
    }
}
